package tomsung.cloud.agdc.service;

import java.util.Date;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import tomsung.cloud.agdc.bean.User;
import tomsung.cloud.agdc.service.UserService;



@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring/springcontext-config.xml")
public class TestUserService {

	@Autowired
	protected UserService service;
	@Test
	public void testRegist()
	{
		User user = new User();
		user.setGroupid(1);
		user.setPassword("bigdata");
		user.setUsername("bigdata");
		user.setRealusername("ABCD");
		user.setAddress("绿地SOHO");
		user.setEmail("lizhiming@tomsung.com");
		user.setTel("18049441261");
		user.setUserurl("/CloudIIMS/image/23f2f78a-f4c1-490f-a021-abeaa6e9d899.png");
		///CloudIIMS/image/4ab77e3d-037e-4276-926d-6a50170466f4.jpg
		
		user.setCreattime(new Date());
		
		User userTmp = service.login("bigdata");
		
		if (userTmp == null)
		{
			int count = service.register(user);
			Assert.assertEquals(1, count);
		}
		else
		{
			Assert.assertEquals("bigdata", userTmp.getUsername());
		}
	}
	
//	@Test
//	public void testDeleteUser()
//	{
//		int count = service.deleteUser(2);
//		Assert.assertEquals(1, count);
//	}

}
